clear 
import delimited "03-Silencing-Study/data/01-clean-data/clean_data.csv"

//Table S9
//main effect
xi: reg withdrawal female male noname i.experiment1, r 
di e(r2_a)
//Study 1 only
xi: reg withdrawal female male noname if experiment1 == 1, r 
di e(r2_a)
//Study 2 only
xi: reg withdrawal female male noname if experiment1 == 0, r 
di e(r2_a)

///By gender
///subset to women only
xi: reg withdrawal female male noname i.experiment1 if gender=="female", r 
di e(r2_a)
///subset to men only
xi: reg withdrawal female male noname i.experiment1 if gender=="male", r 
di e(r2_a)

/// Table S18
xi: reg withdrawal female male noname i.experiment1 if responded == 100, r 
di e(r2_a)
//Study 1 only
xi: reg withdrawal female male noname if experiment1 == 1 & responded == 100, r 
di e(r2_a)
//Study 2 only
xi: reg withdrawal female male noname if experiment1 == 0 & responded == 100, r 
di e(r2_a)
///subset to women only
xi: reg withdrawal female male noname i.experiment1 if gender=="female" & responded == 100, r 
di e(r2_a)
///subset to men only
xi: reg withdrawal female male noname i.experiment1 if gender=="male" & responded == 100, r 
di e(r2_a)

/// Table S24
xi: logit withdrawal female male noname i.experiment1, r 
//Study 1 only
xi: logit withdrawal female male noname if experiment1 == 1, r 
//Study 2 only
xi: logit withdrawal female male noname if experiment1 == 0, r 
///subset to women only
xi: logit withdrawal female male noname i.experiment1 if gender=="female", r
///subset to men only
xi: logit withdrawal female male noname i.experiment1 if gender=="male", r 

/// Table S27
//main effect
xi: reg withdrawal female male noname i.experiment1, r cluster(texterid)
di e(r2_a)
//Study 1 only
xi: reg withdrawal female male noname if experiment1 == 1, r cluster(texterid)
di e(r2_a)
//Study 2 only
xi: reg withdrawal female male noname if experiment1 == 0, r cluster(texterid)
di e(r2_a)

///By gender
///subset to women only
xi: reg withdrawal female male noname i.experiment1 if gender=="female", r cluster(texterid)
di e(r2_a)
///subset to men only
xi: reg withdrawal female male noname i.experiment1 if gender=="male", r cluster(texterid)
di e(r2_a)

/// Table S30
//main effect
xi: ivreg withdrawal i.experiment1 (femaleinstrument maleinstrument nonameinstrument = female male noname), r
di e(r2_a)
//Study 1
xi: ivreg withdrawal (femaleinstrument maleinstrument nonameinstrument = female male noname) if experiment1 == 1, r
di e(r2_a)
//Study 2
xi: ivreg withdrawal (femaleinstrument maleinstrument nonameinstrument = female male noname) if experiment1 == 0, r
//find adjusted r-squared by hand
//n-k = 75228
//n-1 = 75230
//find RSS
di e(rss)
//calculate TSS
summarize withdrawal if experiment1 == 0
gen double wbarErr2 = (withdrawal - r(mean))^2
summarize wbarErr2 if experiment1 == 0
display %15.0f r(sum)
1 - [(3941178/75228)/(3944577/75230)]

///By gender
///subset to women only
xi: ivreg withdrawal i.experiment1 (femaleinstrument maleinstrument nonameinstrument = female male noname) if gender=="female", r 
di e(r2_a)
///subset to men only
xi: ivreg withdrawal i.experiment1 (femaleinstrument maleinstrument nonameinstrument = female male noname) if gender=="male", r 
di e(r2_a)

/// Miscellaneous tables
///By texter gender
///subset to women only
xi: reg withdrawal female male noname i.experiment1 if textergender=="Woman", r
di e(r2_a)
///subset to men only
xi: reg withdrawal female male noname i.experiment1 if textergender=="Man", r 
di e(r2_a)









